# Maintainer: Sergej Pupykin <pupykin.s+arch@gmail.com>
# Contributor: Jason Chu <jason@archlinux.org>
# Contributor: Tom Newsom <Jeepster@gmx.co.uk>

pkgname=xboard
pkgver=4.9.1
pkgrel=3
pkgdesc="Graphical user interfaces for chess"
arch=('loong64' 'x86_64')
url="https://www.gnu.org/software/xboard/"
license=('GPL3')
depends=('texinfo' 'xdg-utils' 'gtk2' 'cairo' 'librsvg')
optdepends=('gnuchess: chess engine'
	    'perl')
validpgpkeys=('47D20669A1ED486C0257C0362A0C7CF1F51BC536')
source=("https://ftp.gnu.org/gnu/${pkgname}/${pkgname}-${pkgver}.tar.gz"{,.sig})
sha256sums=('2b2e53e8428ad9b6e8dc8a55b3a5183381911a4dae2c0072fa96296bbb1970d6'
            'SKIP')

prepare() {
  cd "${pkgname}-${pkgver}"
  sed -i 's/fairymax/gnuchess/g' {xaw,gtk}/xboard.h xboard.conf
}

build() {
  cd "${pkgname}-${pkgver}"
  CFLAGS+=' -fcommon' # https://wiki.gentoo.org/wiki/Gcc_10_porting_notes/fno_common
  ./configure \
    --prefix=/usr \
    --mandir=/usr/share/man \
    --sysconfdir=/etc \
    --with-gtk \
    --enable-zippy
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install
  install -Dm755 "$srcdir"/${pkgname}-${pkgver}/cmail \
    "$pkgdir"/usr/bin/cmail
}
